﻿#ifndef CROSS_PLAT_H_
#define CROSS_PLAT_H_

// 定义跨平台的基本数据类型
#ifdef _LINUX
    typedef unsigned char uint8;
    typedef char int8;
    typedef unsigned short uint16;
    typedef short int16;
    typedef unsigned int uint32;
    typedef int int32;
    typedef int SOCKET;
#endif // end _LINUX

#ifdef WIN32
    typedef unsigned char uint8;
    typedef char int8;
    typedef unsigned short uint16;
    typedef short int16;
    typedef unsigned int uint32;
    typedef int int32;
#endif // end WIN32

// 跨平台SOCKET函数定义
#ifdef WIN32
    
#define ACCEPT(a, b, c)                 accept(a, b, c)
#define CONNECT(a, b, c)                connect(a, b, c)
#define CLOSE(a)                        closesocket(a)
#define RECV(a, b, c, d)                recv(a, (char *)b, c , d)
#define RECVFROM(a, b, c, d, e, f)      recvfrom(a, (char *)b, c, d, (sockaddr *)e, (int *)f)
#define SEND(a, b, c ,d)                send(a, (const char *)b, (int)c , d)
#define SENDTO(a, b, c, d, e, f)        sendto(a, (const char *)b, (int)c, d, e, f)

#endif // end WIN32

#ifdef _LINUX

#define ACCEPT(a, b, c)                 accept(a, b, c)
#define CONNECT(a, b, c)                connect(a, b, c)
#define CLOSE(a)                        close(a)
#define RECV(a, b, c, d)                recv(a, (void *)b, c , d)
#define RECVFROM(a, b, c, d, e, f)      recvfrom(a, (char *)b, c, d, (sockaddr *)e, f)
#define SEND(a, b, c ,d)                send(a, (const char *)b, c , d)
#define SENDTO(a, b, c, d, e, f)        sendto(a, (const char *)b, c, d, e, f)

#endif

#endif